package com.xiaolin.spring.xml;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName SetterInjectTest
 * @Description TODO
 * @Detail setter方法注入
 * @Author MyPC
 * @Date 2020/10/27
 * @Version 1.0
 */
public class SetterInjectTest {
    private Money money;
    private DemoTest demoTest;
    private long age;
    private Integer k;
    private String name;

    public void setMoney(Money money) {
        this.money = money;
    }

    public void setDemoTest(DemoTest demoTest) {
        this.demoTest = demoTest;
    }

    public void setAge(long age) {
        this.age = age;
    }

    public void setK(Integer k) {
        this.k = k;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void main(String[] args) {
        //可从类路径下获取多个xml配置文件
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("setter.xml","demo.xml");
        SetterInjectTest set = applicationContext.getBean("set", SetterInjectTest.class);
        DemoTest demo = applicationContext.getBean("demo", DemoTest.class);
        System.out.println(set.money);
        System.out.println(set.demoTest);
        System.out.println(set.k);
        System.out.println(demo);
    }
}

class Money{

}
